package selcoursesys.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Lpbdz on 2017/4/9.
 */
@Entity
@Table(name = "course", schema = "manage_system", catalog = "")
public class CourseEntity {
    private String courseid;
    private String coursename;
    private Double credit;
    private Integer classhour;
    private String examine;
    private String coursetype;
    private String rid;
    private Integer lnum;
    private Integer cnum;
    private Integer bweek;
    private Integer eweek;
    private String evaluate;
    private String coursetime;
    private AcademyEntity academyEntity;

    public Set getStudent() {
        return student;
    }

    public void setStudent(Set student) {
        this.student = student;
    }

    private AcademyEntity academyByAid;
    private TeacherEntity teacherEntity;
    private Set student=new HashSet();
    public CourseEntity(String coursename,AcademyEntity academyEntity,TeacherEntity teacherEntity,Integer classhour,Double credit,String examine) {
        this.coursename = coursename;
        this.credit = credit;
        this.classhour = classhour;
        this.examine = examine;
        this.academyEntity.setAname(academyEntity.getAname());
        this.teacherEntity.setTname(teacherEntity.getTname());
    }

    public TeacherEntity getTeacherEntity() {

        return teacherEntity;
    }

    public void setTeacherEntity(TeacherEntity teacherEntity) {
        this.teacherEntity = teacherEntity;
    }

    public CourseEntity(){

    }

    public CourseEntity(String courseid,String coursename,double credit,String coursetype){
        this.courseid=courseid;
        this.coursename=coursename;
        this.credit=credit;
        this.coursetype=coursetype;
    }

    public CourseEntity(String courseid, String coursename, Double credit, Integer classhour, String examine, String coursetype, String rid, Integer lnum, Integer cnum, Integer bweek, Integer eweek, String evaluate, String coursetime, AcademyEntity academyEntity) {
        this.courseid = courseid;
        this.coursename = coursename;

        this.credit = credit;
        this.classhour = classhour;
        this.examine = examine;
        this.coursetype = coursetype;
        this.rid = rid;
        this.lnum = lnum;
        this.cnum = cnum;
        this.bweek = bweek;
        this.eweek = eweek;
        this.evaluate = evaluate;
        this.coursetime = coursetime;
        this.academyEntity = academyEntity;
    }

    public void setCredit(double credit) {
        this.credit = credit;
    }

    public void setClasshour(int classhour) {
        this.classhour = classhour;
    }

    public void setLnum(int lnum) {
        this.lnum = lnum;
    }

    public void setCnum(int cnum) {
        this.cnum = cnum;
    }

    public void setBweek(int bweek) {
        this.bweek = bweek;
    }

    public void setEweek(int eweek) {
        this.eweek = eweek;
    }

    public AcademyEntity getAcademyEntity() {
        return academyEntity;
    }

    public void setAcademyEntity(AcademyEntity academyEntity) {
        this.academyEntity = academyEntity;
    }

    @Id
    @Column(name = "courseid")
    public String getCourseid() {
        return courseid;
    }

    public void setCourseid(String courseid) {
        this.courseid = courseid;
    }

    @Basic
    @Column(name = "coursename")
    public String getCoursename() {
        return coursename;
    }

    public void setCoursename(String coursename) {
        this.coursename = coursename;
    }

    @Basic
    @Column(name = "credit")
    public Double getCredit() {
        return credit;
    }

    public void setCredit(Double credit) {
        this.credit = credit;
    }

    @Basic
    @Column(name = "classhour")
    public Integer getClasshour() {
        return classhour;
    }

    public void setClasshour(Integer classhour) {
        this.classhour = classhour;
    }

    @Basic
    @Column(name = "examine")
    public String getExamine() {
        return examine;
    }

    public void setExamine(String examine) {
        this.examine = examine;
    }

    @Basic
    @Column(name = "coursetype")
    public String getCoursetype() {
        return coursetype;
    }

    public void setCoursetype(String coursetype) {
        this.coursetype = coursetype;
    }

    @Basic
    @Column(name = "rid")
    public String getRid() {
        return rid;
    }

    public void setRid(String rid) {
        this.rid = rid;
    }

    @Basic
    @Column(name = "lnum")
    public Integer getLnum() {
        return lnum;
    }

    public void setLnum(Integer lnum) {
        this.lnum = lnum;
    }

    @Basic
    @Column(name = "cnum")
    public Integer getCnum() {
        return cnum;
    }

    public void setCnum(Integer cnum) {
        this.cnum = cnum;
    }

    @Basic
    @Column(name = "bweek")
    public Integer getBweek() {
        return bweek;
    }

    public void setBweek(Integer bweek) {
        this.bweek = bweek;
    }

    @Basic
    @Column(name = "eweek")
    public Integer getEweek() {
        return eweek;
    }

    public void setEweek(Integer eweek) {
        this.eweek = eweek;
    }

    @Basic
    @Column(name = "evaluate")
    public String getEvaluate() {
        return evaluate;
    }

    public void setEvaluate(String evaluate) {
        this.evaluate = evaluate;
    }

    @Basic
    @Column(name = "coursetime")
    public String getCoursetime() {
        return coursetime;
    }

    public void setCoursetime(String coursetime) {
        this.coursetime = coursetime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CourseEntity that = (CourseEntity) o;

        if (courseid != null ? !courseid.equals(that.courseid) : that.courseid != null) return false;
        if (coursename != null ? !coursename.equals(that.coursename) : that.coursename != null) return false;
        if (credit != null ? !credit.equals(that.credit) : that.credit != null) return false;
        if (classhour != null ? !classhour.equals(that.classhour) : that.classhour != null) return false;
        if (examine != null ? !examine.equals(that.examine) : that.examine != null) return false;
        if (coursetype != null ? !coursetype.equals(that.coursetype) : that.coursetype != null) return false;
        if (rid != null ? !rid.equals(that.rid) : that.rid != null) return false;
        if (lnum != null ? !lnum.equals(that.lnum) : that.lnum != null) return false;
        if (cnum != null ? !cnum.equals(that.cnum) : that.cnum != null) return false;
        if (bweek != null ? !bweek.equals(that.bweek) : that.bweek != null) return false;
        if (eweek != null ? !eweek.equals(that.eweek) : that.eweek != null) return false;
        if (evaluate != null ? !evaluate.equals(that.evaluate) : that.evaluate != null) return false;
        if (coursetime != null ? !coursetime.equals(that.coursetime) : that.coursetime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = courseid != null ? courseid.hashCode() : 0;
        result = 31 * result + (coursename != null ? coursename.hashCode() : 0);
        result = 31 * result + (credit != null ? credit.hashCode() : 0);
        result = 31 * result + (classhour != null ? classhour.hashCode() : 0);
        result = 31 * result + (examine != null ? examine.hashCode() : 0);
        result = 31 * result + (coursetype != null ? coursetype.hashCode() : 0);
        result = 31 * result + (rid != null ? rid.hashCode() : 0);
        result = 31 * result + (lnum != null ? lnum.hashCode() : 0);
        result = 31 * result + (cnum != null ? cnum.hashCode() : 0);
        result = 31 * result + (bweek != null ? bweek.hashCode() : 0);
        result = 31 * result + (eweek != null ? eweek.hashCode() : 0);
        result = 31 * result + (evaluate != null ? evaluate.hashCode() : 0);
        result = 31 * result + (coursetime != null ? coursetime.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "aid", referencedColumnName = "aid", nullable = false)
    public AcademyEntity getAcademyByAid() {
        return academyByAid;
    }

    public void setAcademyByAid(AcademyEntity academyByAid) {
        this.academyByAid = academyByAid;
    }
}
